Option Explicit On 
Option Strict On

Imports System
Imports System.Object

Public Class frmTools
    Inherits System.Windows.Forms.Form
    Public Shared objTool As New ToolClass
    Public Shared bUpdate As Boolean = False
    Private Shared iToEdit As Integer = 1  'new tool
    Private Shared curContact As New ContactInfo
    Private Shared bContact As Boolean = False 'tells whether contact exists
    Private Shared curCite As New CiteInfo
    Private Shared bCite As Boolean = False 'tells whether citation exists
    Private Shared bCiteLWC As Boolean = False
    Friend WithEvents button_example As System.Windows.Forms.Button
    Private Shared curCiteLWC As New CiteInfo


#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        iToEdit = 1
        objTool = New ToolClass
        bUpdate = False
        curContact = New ContactInfo
        bContact = False
        curCite = New CiteInfo
        bCite = False
        bCiteLWC = False
        curCiteLWC = New CiteInfo

    End Sub

    Public Sub New(ByVal oToolToEdit As ToolClass)
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        objTool = oToolToEdit
        iToEdit = 2 'edit existing tool

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtDesc As System.Windows.Forms.TextBox
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txtLinks As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
    Friend WithEvents txtInstruct As System.Windows.Forms.TextBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents txtOS As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents txtContact As System.Windows.Forms.TextBox
    Friend WithEvents btnContact As System.Windows.Forms.Button
    Friend WithEvents btnCite As System.Windows.Forms.Button
    Friend WithEvents txtCite As System.Windows.Forms.TextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents btnOK As System.Windows.Forms.Button
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmTools))
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.button_example = New System.Windows.Forms.Button
        Me.btnCancel = New System.Windows.Forms.Button
        Me.btnOK = New System.Windows.Forms.Button
        Me.btnCite = New System.Windows.Forms.Button
        Me.txtCite = New System.Windows.Forms.TextBox
        Me.Label7 = New System.Windows.Forms.Label
        Me.btnContact = New System.Windows.Forms.Button
        Me.txtContact = New System.Windows.Forms.TextBox
        Me.Label6 = New System.Windows.Forms.Label
        Me.Panel2 = New System.Windows.Forms.Panel
        Me.txtOS = New System.Windows.Forms.TextBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.txtInstruct = New System.Windows.Forms.TextBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.txtLinks = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.txtDesc = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.Panel1.SuspendLayout()
        Me.Panel2.SuspendLayout()
        Me.SuspendLayout()
        '
        'Panel1
        '
        Me.Panel1.AutoScroll = True
        Me.Panel1.Controls.Add(Me.button_example)
        Me.Panel1.Controls.Add(Me.btnCancel)
        Me.Panel1.Controls.Add(Me.btnOK)
        Me.Panel1.Controls.Add(Me.btnCite)
        Me.Panel1.Controls.Add(Me.txtCite)
        Me.Panel1.Controls.Add(Me.Label7)
        Me.Panel1.Controls.Add(Me.btnContact)
        Me.Panel1.Controls.Add(Me.txtContact)
        Me.Panel1.Controls.Add(Me.Label6)
        Me.Panel1.Controls.Add(Me.Panel2)
        Me.Panel1.Controls.Add(Me.txtDesc)
        Me.Panel1.Controls.Add(Me.Label1)
        Me.Panel1.Location = New System.Drawing.Point(0, 0)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(600, 425)
        Me.Panel1.TabIndex = 0
        '
        'button_example
        '
        Me.button_example.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.button_example.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.button_example.Image = Global.MetaDoc.My.Resources.Resources.app_help_48x48
        Me.button_example.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.button_example.Location = New System.Drawing.Point(478, 12)
        Me.button_example.Name = "button_example"
        Me.button_example.Size = New System.Drawing.Size(110, 48)
        Me.button_example.TabIndex = 21
        Me.button_example.Text = "EXAMPLE"
        Me.button_example.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.button_example.UseVisualStyleBackColor = True
        '
        'btnCancel
        '
        Me.btnCancel.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnCancel.Image = Global.MetaDoc.My.Resources.Resources.Cancel_16x16
        Me.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnCancel.Location = New System.Drawing.Point(390, 392)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(75, 23)
        Me.btnCancel.TabIndex = 10
        Me.btnCancel.Text = "Cancel"
        Me.btnCancel.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'btnOK
        '
        Me.btnOK.Enabled = False
        Me.btnOK.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnOK.Image = Global.MetaDoc.My.Resources.Resources.Ok_16x16
        Me.btnOK.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnOK.Location = New System.Drawing.Point(309, 392)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(75, 23)
        Me.btnOK.TabIndex = 9
        Me.btnOK.Text = "OK"
        Me.btnOK.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'btnCite
        '
        Me.btnCite.Image = CType(resources.GetObject("btnCite.Image"), System.Drawing.Image)
        Me.btnCite.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnCite.Location = New System.Drawing.Point(367, 109)
        Me.btnCite.Name = "btnCite"
        Me.btnCite.Size = New System.Drawing.Size(75, 23)
        Me.btnCite.TabIndex = 3
        Me.btnCite.Text = "Edit"
        '
        'txtCite
        '
        Me.txtCite.Location = New System.Drawing.Point(131, 111)
        Me.txtCite.Name = "txtCite"
        Me.txtCite.ReadOnly = True
        Me.txtCite.Size = New System.Drawing.Size(230, 20)
        Me.txtCite.TabIndex = 7
        Me.txtCite.TabStop = False
        Me.ToolTip1.SetToolTip(Me.txtCite, "Tool Citation (optional)")
        '
        'Label7
        '
        Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label7.Location = New System.Drawing.Point(12, 114)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(136, 16)
        Me.Label7.TabIndex = 6
        Me.Label7.Text = "Tool Citation (optional)"
        Me.ToolTip1.SetToolTip(Me.Label7, "Tool Citation (optional)")
        '
        'btnContact
        '
        Me.btnContact.Image = CType(resources.GetObject("btnContact.Image"), System.Drawing.Image)
        Me.btnContact.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnContact.Location = New System.Drawing.Point(367, 80)
        Me.btnContact.Name = "btnContact"
        Me.btnContact.Size = New System.Drawing.Size(75, 23)
        Me.btnContact.TabIndex = 2
        Me.btnContact.Text = "Edit"
        '
        'txtContact
        '
        Me.txtContact.Location = New System.Drawing.Point(131, 82)
        Me.txtContact.Name = "txtContact"
        Me.txtContact.ReadOnly = True
        Me.txtContact.Size = New System.Drawing.Size(230, 20)
        Me.txtContact.TabIndex = 4
        Me.txtContact.TabStop = False
        Me.ToolTip1.SetToolTip(Me.txtContact, "Tool Contact (optional)")
        '
        'Label6
        '
        Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label6.Location = New System.Drawing.Point(12, 85)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(136, 16)
        Me.Label6.TabIndex = 3
        Me.Label6.Text = "Tool Contact (optional)"
        Me.ToolTip1.SetToolTip(Me.Label6, "Tool Contact (optional)")
        '
        'Panel2
        '
        Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Panel2.Controls.Add(Me.txtOS)
        Me.Panel2.Controls.Add(Me.Label5)
        Me.Panel2.Controls.Add(Me.txtInstruct)
        Me.Panel2.Controls.Add(Me.Label4)
        Me.Panel2.Controls.Add(Me.txtLinks)
        Me.Panel2.Controls.Add(Me.Label3)
        Me.Panel2.Controls.Add(Me.Label2)
        Me.Panel2.Location = New System.Drawing.Point(15, 138)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(450, 248)
        Me.Panel2.TabIndex = 4
        Me.ToolTip1.SetToolTip(Me.Panel2, "Tool Access Information")
        '
        'txtOS
        '
        Me.txtOS.AcceptsReturn = True
        Me.txtOS.Location = New System.Drawing.Point(4, 186)
        Me.txtOS.Multiline = True
        Me.txtOS.Name = "txtOS"
        Me.txtOS.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtOS.Size = New System.Drawing.Size(440, 50)
        Me.txtOS.TabIndex = 6
        Me.ToolTip1.SetToolTip(Me.txtOS, "Tool Computer and Operating System (optional)")
        '
        'Label5
        '
        Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label5.Location = New System.Drawing.Point(3, 167)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(248, 16)
        Me.Label5.TabIndex = 5
        Me.Label5.Text = "Tool Computer and Operating System (optional)"
        Me.ToolTip1.SetToolTip(Me.Label5, "Tool Computer and Operating System (optional)")
        '
        'txtInstruct
        '
        Me.txtInstruct.AcceptsReturn = True
        Me.txtInstruct.Location = New System.Drawing.Point(4, 114)
        Me.txtInstruct.Multiline = True
        Me.txtInstruct.Name = "txtInstruct"
        Me.txtInstruct.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtInstruct.Size = New System.Drawing.Size(440, 50)
        Me.txtInstruct.TabIndex = 4
        Me.ToolTip1.SetToolTip(Me.txtInstruct, "Tool Access Instructions")
        '
        'Label4
        '
        Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.Location = New System.Drawing.Point(3, 95)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(152, 16)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "Tool Access Instructions"
        Me.ToolTip1.SetToolTip(Me.Label4, "Tool Access Instructions")
        '
        'txtLinks
        '
        Me.txtLinks.AcceptsReturn = True
        Me.txtLinks.Location = New System.Drawing.Point(3, 42)
        Me.txtLinks.Multiline = True
        Me.txtLinks.Name = "txtLinks"
        Me.txtLinks.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtLinks.Size = New System.Drawing.Size(440, 50)
        Me.txtLinks.TabIndex = 2
        Me.ToolTip1.SetToolTip(Me.txtLinks, "Online Linkage(s) [URLs]" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Use full URL")
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(3, 23)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(152, 16)
        Me.Label3.TabIndex = 1
        Me.Label3.Text = "Online Linkage(s) [URLs]"
        Me.ToolTip1.SetToolTip(Me.Label3, "Online Linkage(s) [URLs]" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Use full URL")
        '
        'Label2
        '
        Me.Label2.Dock = System.Windows.Forms.DockStyle.Top
        Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.Location = New System.Drawing.Point(0, 0)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(446, 23)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "Tool Access Information"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.TopCenter
        Me.ToolTip1.SetToolTip(Me.Label2, "Tool Access Information")
        '
        'txtDesc
        '
        Me.txtDesc.AcceptsReturn = True
        Me.txtDesc.Location = New System.Drawing.Point(15, 26)
        Me.txtDesc.Multiline = True
        Me.txtDesc.Name = "txtDesc"
        Me.txtDesc.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtDesc.Size = New System.Drawing.Size(450, 50)
        Me.txtDesc.TabIndex = 1
        Me.ToolTip1.SetToolTip(Me.txtDesc, "Analytical Tool Description")
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(12, 9)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(160, 23)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Analytical Tool Description"
        Me.ToolTip1.SetToolTip(Me.Label1, "Analytical Tool Description")
        '
        'ToolTip1
        '
        Me.ToolTip1.IsBalloon = True
        Me.ToolTip1.ShowAlways = True
        Me.ToolTip1.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info
        '
        'frmTools
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(600, 427)
        Me.ControlBox = False
        Me.Controls.Add(Me.Panel1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmTools"
        Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Analytical Tool"
        Me.Panel1.ResumeLayout(False)
        Me.Panel1.PerformLayout()
        Me.Panel2.ResumeLayout(False)
        Me.Panel2.PerformLayout()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmTools_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sList As String = ""

        If (iToEdit = 1) Then  'a new tool to be described
        Else   'fill the form with information to be edited
            txtDesc.Text = objTool.ToolDesc
            txtLinks.Text = objTool.ToolLink
            txtInstruct.Text = objTool.ToolAccess
            txtOS.Text = objTool.ToolOS
            If (objTool.boolContact = True) Then
                curContact = objTool.ToolContact
                If (curContact.PrimaryPerson = True) Then
                    sList = curContact.Person
                Else
                    sList = curContact.Organization
                End If
                txtContact.Text = sList
            End If
            If (objTool.boolCitation = True) Then
                curCite = objTool.ToolCite
                bCiteLWC = objTool.boolCiteLWC
                curCiteLWC = objTool.ToolCiteLWC
                sList = curCite.Author & "   " & curCite.Title
                txtCite.Text = sList
            End If
        End If
    End Sub

    Private Sub btnContact_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnContact.Click
        Dim slist As String = ""
        Dim fToolCon As New frmContact(curContact, iToEdit)

        fToolCon.ShowDialog()
        If (fToolCon.bUpdate = True) Then
            curContact = fToolCon.conInfo
            bContact = True
            If (curContact.PrimaryPerson = True) Then
                slist = curContact.Person
            Else
                slist = curContact.Organization
            End If
            txtContact.Text = slist
        End If
    End Sub

    Private Sub btnCite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCite.Click
        Dim slist As String = ""
        Dim iTime As Integer = frmMetaMain.intTimeStyle

        Dim fToolCite As New frmCiteInfo(curCite, curCiteLWC, bCiteLWC, iTime)
        fToolCite.ShowDialog()

        If (fToolCite.bUpdate = True) Then
            bCite = True
            curCite = fToolCite.newCite
            slist = curCite.Author & "   " & curCite.Title
            txtCite.Text = slist
            If (fToolCite.bLWC = True) Then
                bCiteLWC = True
                curCiteLWC = fToolCite.newLWC
            End If
        End If
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        objTool.ToolDesc = txtDesc.Text
        objTool.ToolLink = txtLinks.Text
        objTool.ToolAccess = txtInstruct.Text
        objTool.ToolOS = txtOS.Text
        If (bContact = True) Then
            objTool.boolContact = True
            objTool.ToolContact = curContact
        End If
        If (bCite = True) Then
            objTool.boolCitation = True
            objTool.ToolCite = curCite
            objTool.boolCiteLWC = bCiteLWC
            objTool.ToolCiteLWC = curCiteLWC
        End If
        bUpdate = True
        Me.Dispose()
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        bUpdate = False
        Me.Dispose()
    End Sub

    Public Function getUpdated() As Boolean
        Return bUpdate
    End Function
    Public Function getObjTool() As ToolClass
        Return objTool
    End Function

    Private Sub txtDesc_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDesc.TextChanged
        validateOK()
    End Sub

    Private Sub txtInstruct_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInstruct.TextChanged
        validateOK()
    End Sub
    Private Sub validateOK()
        If txtDesc.Text.Trim() = "" Or txtInstruct.Text.Trim() = "" Then btnOK.Enabled = False Else btnOK.Enabled = True
    End Sub

    Private Sub button_example_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_example.Click
        Dim helpForm As dialog_help = New dialog_help("Tools")
        helpForm.ShowDialog()
    End Sub
End Class
